package com.it.confignacos.Controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/config")
@RefreshScope  // 通过@RefreshScope来动态感知nacos的配置文件变化，但@Value无法动态感知
public class ReadYamlController {

    @Value("${user.name}")
    public String name;

    @Value("${user.age}")
    public Integer age;

    @RequestMapping("/show")
    public String show(){
        return name+"/"+age;
    }
}
